
import os
import time
""" 
    公共元素
"""

class BasePage:
    """ 初始化变量"""
    def __init__(self,driver):
        self.driver = driver
        self.driver.implicitly_wait(10)

    """ 元素定位"""
    def find_element(self, *arg):
        return self.driver.find_element(*arg)

    """ 弹框处理"""
    def alert_deel(self):
        ale = self.driver.switch_to.alert
        text = ale.text
        return ale,text

    """ 关闭页面 """
    def close_window(self):
        self.driver.close()

    """ 进入表单 """
    def swith_to_frame(self, frame_ele):
        return self.driver.switch_to.frame(frame_ele)

    """ 返回父表单 """
    def switch_to_parentframe(self):
        return self.driver.switch_to.parent_frame()

    """ 返回默认表单 """
    def switch_to_defualtcontent(self):
        return self.driver.switch_to.default_content()

    """ 截图"""
    # def get_pic(self):
    #     self.pic_path = os.getcwd().replace("\\","/") + "/test_log/shot_screen/"
    #     file_path = self.pic_path + "%s.png"%time.strftime("%Y-%m-%d %H_%M_%S")
    #     img = ImageGrab.grab()
    #     img.save(file_path)


